<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>主页</title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../css/aui-flex.css" />
    <link rel="stylesheet" type="text/css" href="../css/swiper.min.css" />
    <style type="text/css">
        img.icon {
            display: block;
            margin: 0 auto;
            width: 60%;
            border-radius: 50%;
        }

        .margin-top-180 {
            margin-top: 0.05rem;
        }

        .bodycss {
            background-color: rgba(0, 0, 0, 0.0) !important;
            height: 7rem;
            width: 100%;
            display: block;
        }

        #indexfenlei_swiper>.swiper-slide {
            /* Center slide text vertically */
            position: relative;
            float: left;
            display: -webkit-box;
            display: -ms-flexbox;
            display: -webkit-flex;
            display: flex;
            -webkit-box-pack: center;
            -ms-flex-pack: center;
            -webkit-justify-content: center;
            justify-content: center;
            -webkit-box-align: center;
            -ms-flex-align: center;
            -webkit-align-items: center;
            align-items: center;
            width: 20%;
            border: 0px solid red;
            padding-top: 3px !important;
        }

        .swiper-pagination-bullet {
            width: 20px;
            height: 3px;
            border-radius: 0px;
            background-color: rgba(0, 0, 0, 0.5);
            margin: 0 0px !important;
        }

        .swiper-pagination-bullet-active {
            width: 20px;
            background-color: #FF1493;
        }

        #indexbanner_swiper {
            height: 140px;
            margin-top: 5px;
            width: 95%;
        }

        .imagecache_fenlei {
            height: 45px;
            width: 50px;
        }
    </style>
</head>

<body style="background-color:rgba(0,0,0,0.0)">
    <div class="bodycss">
        <div class="swiper-container" id="indexbanner_swiper">
            <div class="swiper-wrapper" id="indexbanner">
                <div class="swiper-slide" onclick="openindexfenleiurl_new('https://mst.vip.com/XIVjYQGmQhVJ2XHntuXRsw.php?wq=1&wapid=mst_100004000&_src=mst&extra_banner=115004000&nova=1&mst_page_type=guide')"><img class="imagecache" src="../image/banner_def.jpg" onerror="this.src='../image/banner_def.jpg'" style="height:140px;width:100%;border-radius: 8px;" /></div>
            </div>
            <div class="swiper-pagination"></div>
        </div>
    </div>
    <section style="background-color:#FFFFFF">
        <section class="aui-content aui-margin-b-15 margin-top-180 aui-margin-l-5 aui-margin-r-5" style="border-radius:5px;border:0px solid #eee">
            <div class="aui-grid aui-padded-t-10 aui-padded-b-10">
                <div class="aui-row aui-row-padded">
                    <div class="swiper-container" id="indexfenlei_swiper">
                        <div class="swiper-wrapper" id="indexfenlei">
                            <div class="aui-flex-col aui-flex-middle aui-flex-center aui-flex-item-12 aui-hide" id="default_fenlei">
                                <div class="aui-flex-item-20  aui-padded-b-0 aui-padded-t-5">
                                    <img src="../image/fltb.png" class="icon imagecache aui-text-center">
                                    <div class="aui-font-size-12 aui-text-center">淘宝</div>
                                    <p class="aui-font-size-10 aui-text-center">最高省90%</p>
                                </div>
                                <div class="aui-flex-item-20  aui-padded-b-0 aui-padded-t-5 aui-flex-center">
                                    <img src="../image/flvip.png" class="icon imagecache aui-text-center">
                                    <div class="aui-font-size-12 aui-text-center">唯品会</div>
                                    <p class="aui-font-size-10 aui-text-center">最高省90%</p>
                                </div>
                                <div class="aui-flex-item-20  aui-padded-b-0 aui-padded-t-5">
                                    <img src="../image/fljd.png" class="icon imagecache aui-text-center">
                                    <div class="aui-font-size-12 aui-text-center">京东</div>
                                    <p class="aui-font-size-10 aui-text-center">最高省90%</p>
                                </div>
                                <div class="aui-flex-item-20  aui-padded-b-0 aui-padded-t-5">
                                    <img src="../image/flmgj.png" class="icon imagecache aui-text-center">
                                    <div class="aui-font-size-12 aui-text-center">蘑菇街</div>
                                    <p class="aui-font-size-10 aui-text-center">最高省90%</p>
                                </div>
                                <div class="aui-flex-item-20  aui-padded-b-0 aui-padded-t-5">
                                    <img src="../image/pdd.gif" class="icon imagecache aui-text-center">
                                    <div class="aui-font-size-12 aui-text-center">拼多多</div>
                                    <p class="aui-font-size-10 aui-text-center">最高省90%</p>
                                </div>
                                <div class="aui-flex-item-20  aui-padded-b-0 aui-padded-t-5">
                                    <img src="../image/flelm.gif" class="icon imagecache aui-text-center">
                                    <div class="aui-font-size-12 aui-text-center">饿了么</div>
                                    <p class="aui-font-size-10 aui-text-center">最高省90%</p>
                                </div>
                                <div class="aui-flex-item-20  aui-padded-b-0 aui-padded-t-5">
                                    <img src="../image/flsn.png" class="icon imagecache aui-text-center">
                                    <div class="aui-font-size-12 aui-text-center">苏宁</div>
                                    <p class="aui-font-size-10 aui-text-center">最高省90%</p>
                                </div>
                                <div class="aui-flex-item-20  aui-padded-b-0 aui-padded-t-5">
                                    <img src="../image/fljhs.png" class="icon imagecache aui-text-center">
                                    <div class="aui-font-size-12 aui-text-center">聚划算</div>
                                    <p class="aui-font-size-10 aui-text-center">最高省90%</p>
                                </div>
                                <div class="aui-flex-item-20 aui-padded-b-0 aui-padded-t-5">
                                    <img src="../image/flpyby.png" class="icon imagecache aui-text-center">
                                    <div class="aui-font-size-12 aui-text-center">偏远包邮</div>
                                    <p class="aui-font-size-10 aui-text-center">最高省90%</p>
                                </div>
                                <div class="aui-flex-item-20  aui-padded-b-0 aui-padded-t-5">
                                    <img src="../image/fltmcs.png" class="icon imagecache aui-text-center">
                                    <div class="aui-font-size-12 aui-text-center">天猫超市</div>
                                    <p class="aui-font-size-10 aui-text-center">最高省90%</p>
                                </div>
                            </div>
                        </div>
                        <div class="swiper-pagination"></div>
                    </div>
                </div>
            </div>
            <div class="aui-flex-col aui-flex-item-12 aui-flex-center aui-flex-middle  aui-padded-5 aui-bg-default aui-border-radius" style="height:32px;">
                <div class="aui-flex-item-2 aui-flex-left"><img src="../image/toutiao.png" width="100%" /></div>
                <div class="aui-flex-item-10 aui-flex-left">
                    <div class="swiper-container aui-margin-l-5" id="gonggao_swiper">
                        <div class="swiper-wrapper" id="gonggao" style="height:32px;">

                        </div>
                    </div>
                </div>
            </div>
        </section>
        <section id="diycontent"></section>
        <section id="indexad" class="aui-flex-col aui-margin-b-10">

        </section>
        <div class="aui-content aui-border-radius" style="border:0px solid #ddd">

            <div class="aui-card-list-header">
                <div>
                    <label class="aui-label aui-bg-tag-quan">榜单</label>
                    <span class="aui-text-danger aui-font-size-12"><b>近2小时热销</b></span>
                </div>
            </div>
            <div class="aui-flex-col aui-flex-center aui-flex-middle" id="div_goods_list">
            </div>

        </div>
    </section>
    <!--返回顶部-->
    <div class="gotoback" onclick="gotoback()" id="gotoback">
        <img src="../image/gotoback.png">
    </div>
    <!--加载loading-->
    <div class="index_loading">
        <img src="../image/index_loading.gif" />
        <span>加载中,请稍后...</span>
    </div>
    <div class="loading_main">
        <img src="../image/loading_main.gif" />
        <span>加载中,请稍后...</span>
    </div>
    <div class="temporarily_data" style="display:none;">
        <img src="../image/no_date.png" />
    </div>
    <script id="indexfenleitmpl" type="text/x-dot-template">
        {{? it.length>0}} {{for (var i=0; i
        <it.length; i++) {}} <div class="aui-col-5 swiper-slide aui-padded-b-0 aui-padded-t-5" tapmode onclick="openindexfenleiurl_new('{{=it[i].url}}')">
            <img src="{{=it[i].pic}}" class="icon imagecache_fenlei" onerror="this.src='../image/taobao.png'">
            <div class="aui-font-size-12">{{=it[i].name}}</div>
            <p class="aui-font-size-10">{{=it[i].tag}}</p>
            </div>
            {{ } }} {{?}}
    </script>
    <script id="tmpl_goods_list" type="text/x-dot-template">
        {{~it:vo:index}}
        <div class="aui-flex-item-6 aui-padded-5" tapmode onclick="openWinto('detail_win','widget://html/good_pdd_jd_detail_win',{source_type:'{{=sorts_data.source_type}}',goods_id:'{{=vo.goods_id}}',picurl:'{{=vo.picurl}}',picurls:'{{=vo.picurls}}',goods_name:'{{=vo.goods_name}}',sales:'{{=vo.sales}}',price:'{{=vo.price}}',price_pg:'{{=vo.price_pg}}',commission:'{{=vo.commission}}',price_after:'{{=vo.price_after}}',discount:'{{=vo.discount}}',start_time:'{{=vo.start_time}}',end_time:'{{=vo.end_time}}',cid:'{{=vo.pf_cid}}',cid1:'{{=vo.pf_cid1}}',cid2:'{{=vo.pf_cid2}}',cid3:'{{=vo.pf_cid3}}',couponurl:'{{=vo.couponurl}}',shopname:'{{=vo.shopname}}',shopid:'{{=vo.shopid}}',user_type:'{{=vo.user_type}}'})">
            <div class="aui-flex-row aui-flex-center aui-flex-middle aui-border-radius" style="box-shadow: 0 0 50px #dddddd;">
                <div class="pic aui-margin-0 aui-text-center"><img class="aui-border-radius-top" style="background-color:#fff" onerror="this.src='../image/load-img.png'" src="../image/load-img.png" data-echo="{{=vo.picurl}}" height="180px" width="100%" max-height="180px"></div>
                <div class="aui-padded-5" style="background-color:#fff">
                    <div class="itemtitle aui-ellipsis-2">{{? sorts_data.source_type=='pdd'}}<label class="pdd_font_style">拼多多</label>{{?? sorts_data.source_type=='jd'}}<label class="jd_font_style">JD</label>{{??}}<label class="aui-iconfont  aui-icon-{{?vo.user_type=='0'}}taobao aui-text-warning{{??}}tianmao aui-text-danger{{?}}"></label>{{?}}
                        <label class="aui-font-size-14">{{=vo.goods_short_name}}{{=vo.goods_short_name}}{{=vo.goods_short_name}}{{=vo.goods_short_name}}</label>
                    </div>
                    <div class="aui-flex-col aui-flex-center aui-flex-middle">
                        <div class="aui-flex-item-12  aui-text-left"><label class="aui-font-size-18" style="color:#FF3E96">￥{{=vo.price_after}}</label><del class="aui-font-size-12 aui-text-color-757575">￥{{=(vo.discount * 1+vo.price_after*1).toFixed(2)}}</del></div>
                        <div class="aui-flex-item-7 aui-text-left">
                            <label class="aui-label aui-bg-tag-quan aui-quan"><i>券{{=(vo.discount*1).toFixed(0)||0}}元</i></label>
                        </div>
                        <div class="aui-flex-item-5 aui-text-left"><label class="aui-font-size-12 aui-text-color-757575">已售{{?sorts_data.source_type=='pdd'}}{{=vo.sales}}{{??}}{{=changeW(vo.sales)}}{{?}}</label></div>
                    </div>
                </div>
                <div style="color:#FFF;width:100%" class="aui-border-radius-bottom aui-text-center aui-font-size-14 {{? index%2==0}} aui-bg-tag-{{?sorts_data.source_type=='tb'}}tb{{??sorts_data.source_type=='pdd'}}pdd{{??}}vip{{?}}{{??}}aui-bg-tag-quan-1{{?}} "><label class=" aui-iconfont   aui-padded-r-5"></label>预估赚{{? isLoginOr()}}{{=(vo.commission * 0.01 * isLoginOr().yjrate).toFixed(2)}}{{??}}{{=(vo.commission * 1).toFixed(2)}}{{?}}元
                </div>
            </div>
        </div>
        {{~}}
    </script>
    <script id="indexad_tmpl" type="text/x-dot-template">
        {{? it.length>0}} {{for(var i=0;i
        <it.length;i++) { }} <div class="aui-flex-item-6 aui-flex-left aui-padded-5" tapmode onclick="openindexfenleiurl_new('{{=it[i].url}}')">
            <img class="imagecachead" src="{{=it[i].pic}}" onerror="this.src='../image/load-img.png'" width="100%" style="border-radius:5px" />
            </div>
            {{ } }} {{?}}
    </script>
    <script id="indexbanner_tmpl" type="text/x-dot-template">
        {{? it.length>0}} {{for(var i=0;i
        <it.length;i++) { }} <div class="swiper-slide" tapmode onclick="openindexfenleiurl_new('{{=it[i].url}}')"><img class="imagecache_banner" src="{{=it[i].pic}}" onerror="this.src='../image/default_banner.png'" style="height:140px;width:100%;border-radius: 8px;" /></div>
            {{ } }} {{?}}
    </script>
    <script id="gonggao_tmpl" type="text/x-dot-template">
        {{? it.length>0}} {{for(var i=0;i
        <it.length;i++) { }} <div class="swiper-slide aui-font-size-12 aui-text-left aui-ellipsis-1" style="height:32px;line-height:32px" tapmode onclick="openindexfenleiurl_new('{{=it[i].url}}','{{=it[i].opentype}}')">{{=it[i].title}}</div>
            {{ } }} {{?}}
    </script>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/config.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script type="text/javascript" src="../script/doT.min.js"></script>
<script type="text/javascript" src="../script/zepto.min.js"></script>
<script type="text/javascript" src="../script/swiper.min.js"></script>
<script type="text/javascript" src="../script/echo.min.js"></script>
<script type="text/javascript" src="../script/aui-dialog.js"></script>
<script type="text/javascript">
    var mySwiper_fenlei, indexbaner_swiper, sInt = null,
        pageParam,
        data = {};
    apiready = function() {
        echo.init({
            offset: 0,
            throttle: 250,
            unload: false,
        });
        Object.assign(sorts_data, api.pageParam);
        api.parseTapmode();
        bodySrollChangeHeader();
        init_banner_swiper();
        initIndexFenleiSwiper();
        if ($api.getStorage('xieyi') != 1) {
            var dialog = new auiDialog({});
            dialog.alert({
                title: "温馨提示",
                msg: "感谢您对优券联盟一直以来的信任！<p class='aui-text-left'>我们深知个人信息对用户的重要性，将按法律法规要求，采取相应保护措施，尽力保障您的个人信息安全可控。</p><p class='aui-text-danger'>鉴此，我们特向您说明如下：</p><p class='aui-text-left'>您在使用优券联盟各项产品或服务时，优券联盟将获取存储权限，不会收集个人信息。请认真阅读<label class='aui-text-danger' onclick='xieyi(52)'>《服务协议》</label>和<label class='aui-text-danger' onclick='xieyi(53)'>《隐私政策》</label>。</p><p>点击同意即表示您同意并接受全部条款</p>",
                buttons: ['不同意', '同意']
            }, function(ret) {
                if (ret.buttonIndex == 1) {
                    api.closeWidget({
                        silent: true
                    });
                } else {
                    $api.setStorage('xieyi', 1);
                }
            });
        }
        setAppNotSroll();
        get_index_banner();
        getIndexFenlei();
        getIndexAd();
        init_gonggao();
        getindexGoodsList();
        getMoreGoods(function() {
            getindexGoodsList(true);
        });

        pullDown(function() {
            init_gonggao();
            getindexGoodsList();
        });
    }

    function getindexGoodsList(more) {
        if (more === true) {
            sorts_data.pageindex++;
        }
        getGoodsList(sorts_data.source_type, sorts_data, more);
    }

    function get_index_banner() {
        var index_banner_info = getStorage('getBanner');
        var div = '';
        if (index_banner_info) {
            for (let i in index_banner_info) {
                i > 0 && indexbaner_swiper.appendSlide('<div class="swiper-slide" tapmode onclick=openindexfenleiurl_new("' + index_banner_info[i].url + '")><img onload="imageCache(this)" class="imagecache_banner" src="' + index_banner_info[i].pic +
                    '"  style="height:140px;width:100%;border-radius: 8px;" /></div>');
            }
            indexbaner_swiper.update();
        } else {
            postData(API_URL + 'getBanner', {
                apiname: 'getBanner'
            }, function(ret, err) {
                if (ret.code == 1) {
                    setStorage('getBanner', ret.data);
                    index_banner_info = ret.data;
                    for (let i in index_banner_info) {
                        i > 0 && indexbaner_swiper.appendSlide('<div class="swiper-slide" onclick=openindexfenleiurl_new("' + index_banner_info[i].url + '")><img onload="imageCache(this)" class="imagecache_banner" src="' + index_banner_info[
                            i].pic + '"  style="height:140px;width:100%;border-radius: 8px;" /></div>');
                    }
                    indexbaner_swiper.update();
                } else {
                    showToast(TipInfo.data_busy);
                }
            });
        }

    }

    function initIndexFenleiSwiper() {
        mySwiper_fenlei = new Swiper('#indexfenlei_swiper', {
            slidesPerView: 5,
            slidesPerColumn: 2,
            spaceBetween: 0,
            pagination: {
                el: '.swiper-pagination',
            },
            on: {
                touchStart: function(event) {
                    api.setFrameGroupAttr({
                        name: 'index_frame_list',
                        scrollEnabled: false
                    });
                    api.setFrameAttr({
                        name: api.frameName,
                        bounces: false
                    });
                },
                touchEnd: function(event) {
                    api.setFrameGroupAttr({
                        name: 'index_frame_list',
                        scrollEnabled: true
                    });
                    api.setFrameAttr({
                        name: api.frameName,
                        bounces: true
                    });
                }
            }
        });
    }

    function init_banner_swiper() {
        indexbaner_swiper = new Swiper('#indexbanner_swiper', {
            autoplay: {
                delay: 3000,
                stopOnLastSlide: false,
                disableOnInteraction: false,
            },
            pagination: {
                el: '.swiper-pagination',
            },
            on: {
                touchStart: function(event) {
                    api.setFrameGroupAttr({
                        name: 'index_frame_list',
                        scrollEnabled: false
                    });
                    api.setFrameAttr({
                        name: api.frameName,
                        bounces: false
                    });
                },
                touchEnd: function(event) {
                    api.setFrameGroupAttr({
                        name: 'index_frame_list',
                        scrollEnabled: true
                    });
                    api.setFrameAttr({
                        name: api.frameName,
                        bounces: true
                    });
                },
                slideChangeTransitionStart: function(event) {
                    var changeindexbg = 'changeBannerBg(' + this.realIndex + ');';
                    api.execScript({
                        name: 'root',
                        frameName: "index_win",
                        script: changeindexbg
                    });
                }
            },
        });
    }

    //首页广告

    function getIndexAd() {
        var ad = getStorage('indexAd');
        if (ad) {
            setDotTmpl('indexad_tmpl', 'indexad', ad);
            iCache($('.imagecachead'));
        } else {
            postData(API_URL + 'getIndexad', {}, function(ret) {
                if (ret.code == 1) {
                    //console.log(JSON.stringify(ret.data));
                    setStorage('indexAd', ret.data);
                    setDotTmpl('indexad_tmpl', 'indexad', ret.data);
                    iCache($('.imagecachead'));
                }
            });
        }

    }
    //首页分类
    function getIndexFenlei() {
        var indexfenlei = '';
        indexfenlei = getStorage("indexfenlei");
        if (indexfenlei) {
            if ($api.getStorage('appSetInfo').cache_time != 10000) {
                setDotTmpl("indexfenleitmpl", "indexfenlei", indexfenlei);
                iCache($('.imagecache_fenlei'));
                mySwiper_fenlei.update();
            }
        } else {
            postData(API_URL + 'getIndexFenlei', {}, function(ret, err) {
                if (ret.code == 1) {
                    if ($api.getStorage('appSetInfo').cache_time != 10000) {
                        indexfenlei = setStorage('indexfenlei', ret.data);
                        setDotTmpl("indexfenleitmpl", "indexfenlei", ret.data);
                        iCache($('.imagecache_fenlei'));
                        mySwiper_fenlei.update();
                    }
                } else { //无网络无本地缓存使用
                    showToast('获取数据错误~');
                }
            });
        }
    }

    function init_gonggao() {
        postData(API_URL + 'getGonggao', {}, function(ret, err) {
            if (ret.code == 1) {
                setDotTmpl('gonggao_tmpl', 'gonggao', ret.data);
                var gonggao_swiper = new Swiper('#gonggao_swiper', {
                    direction: 'vertical',
                    autoplay: true,
                    autoHeight: true,
                    on: {
                        touchStart: function(swiper) {
                            api.setFrameAttr({
                                name: api.frameName,
                                bounces: false
                            });
                        },
                        touchEnd: function(swiper) {
                            api.setFrameAttr({
                                name: api.frameName,
                                bounces: true
                            });
                        }
                    }
                });
            }
        })
    }
</script>

</html>
